namespace Geekeradmin.Middleware
{
    public class XssMiddleware
    {
        private readonly RequestDelegate _next;

        public XssMiddleware(RequestDelegate next)
        {
            _next = next;
        }

        public async Task Invoke(HttpContext context)
        {
            context.Response.Headers["X-XSS-Protection"] = "1; mode=block";
            await _next(context);
        }
    }

    public static class XssMiddlewareExtensions
    {
        public static IApplicationBuilder UseXssMiddleware(this IApplicationBuilder builder)
        {
            return builder.UseMiddleware<XssMiddleware>();
        }
    }
}
